﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T15OOP2
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                // Product p = new Product();抽象类不可实例化
                Book book = new Book();//具有  默认无参构造函数能够正确初始化，无需显式调用
                book.Name = "天龙八部";
                book.Price = 30.0M;
                book.Isbn = "12345678941525";
                book.Intro = "江湖传奇";
                book.Show();
                book.ShowDetail();
                //book = null;//谨慎使用，可以提高内容使用效率
                Console.WriteLine("***************");
                Digital digital = new Digital();
                digital.Name = "蓝牙音箱";
                digital.Price = 399M;
                digital.Barcode = "12345678";

                Action buy = new Action();
                buy.Buy(book);
                buy.Buy(digital);
                buy.Show();
            }
            catch (ArgumentException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("输入信息有误！") ;
            }catch(Exception)
            {
                Console.WriteLine("其他错误");
            }

            //内存垃圾回收
            System.GC.Collect();
            Console.ReadKey();

        }
    }
}
